package com.woniuxy.gateway.config;

import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.Arrays;
import java.util.List;

/**
 * swagger资源配置
 */
@Component
public class SwaggerResourceConfig implements SwaggerResourcesProvider {
    /**
     * 资源仓库
     * @return
     */
    @Override
    public List<SwaggerResource> get() {
        return Arrays.asList(
            createSR("/admin/v2/api-docs","系统管理服务"),
            createSR("/fund/v2/api-docs","流水管理服务"),
            createSR("/goods/v2/api-docs","典当物品管理服务"),
            createSR("/order/v2/api-docs","订单管理服务"),
            createSR("/product/v2/api-docs","商品管理服务"),
            createSR("/user/v2/api-docs","用户服务")
        );
    }

    /**
     * 创建资源
     * @param url 地址
     * @param name 名称
     * @return
     */
    private SwaggerResource createSR(String url,String name){
        SwaggerResource sr = new SwaggerResource();
        sr.setLocation(url);
        sr.setName(name);
        return sr;
    }
}
